(function(){
	if (loadItem("web3js_wallet")){
		if(!confirm("您已经有一个内置账号了，想要重新创建吗？")) return;
	}
	getNode("pswd1").onkeyup=function(){
		if (checkPassword(this.value)) getNode("ok").onclick = go;
		else getNode("ok").onclick = "";
	};
	//显示或隐藏密码
	setEye(1);
	setEye(2);
	async function go(){
		var pswd1=getNode("pswd1").value;
		var pswd2=getNode("pswd2").value;
		var phrase = getNode("mnemonic").value;
		if (pswd1!=pswd2){
			setNodeText("errmsg","验证密码不一致");
			return;
		}
		if (phrase.split(" ").length != 12){
			setNodeText("errmsg","请输入12个助记词");
			return;
		}
        display("before",false);
        setLoading(1);
		var wallet;
        try{
			//用助记词导入钱包
            wallet = await inportWallet(pswd1,phrase);
        }catch(e){
            setNodeText("errmsg","助记词不正确");
            display("before",true);
            return;
        }
        setLoading(0);
        display("after",true);
        getNode("pubAddress").innerText = publicParam.address;
		//点击建立连接
        getNode("finish").onclick=()=>{
            connectWallet(wallet);
            goto("home");
        };
	};
})();